package com.dianjing.dianqun.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.dianjing.dianqun.common.base.CrudService;
import com.dianjing.dianqun.dao.SiteMapper;
import com.dianjing.dianqun.model.Site;

@Service
@Transactional
public class SiteService extends CrudService<SiteMapper, Site>{

	@Autowired
	private SiteMapper siteMapper;

	public List<Site> findAll() {
		return siteMapper.selectAllSite();
	}

	public List<Site> findByQuery(String keyword) {
		return siteMapper.findByQuery(keyword);
	}

	/**
	 * 根据 站点id查询 纵访问量
	 * @param siteId
	 * @return
	 */
	public Long selectFlowCountBySiteId(Integer siteId) {
		return siteMapper.selectFlowCountBySiteId(siteId);
	}
	/**
	 * 按浏览量查询site
	 * @param siteId
	 * @return
	 */
	public List<Site> findSiteByView() {
		return siteMapper.findSiteByView();
	}

	/**
	 * 按关注度查询site
	 * @param siteId
	 * @return
	 */
	public List<Site> findSiteByFollows() {
		return siteMapper.findSiteByFollows();
	}
	
	/**
	 * 根据用户id查询对应的站点
	 * @param userId
	 * @return
	 */
	public Site selectSitelByUserId(Integer userId) {
		return siteMapper.selectSitelByUserId(userId);
	}

}
